package com.yiren.manager.ctrl.test;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yiren.core.utils.HTTPResult;
import com.yiren.entity.YrTestResultLevel;
import com.yiren.manager.ctrl.GenericController;
import com.yiren.manager.form.test.YrTestResultLevelForm;
import com.yiren.manager.service.iface.test.YrTestResultLevelService;
import com.yiren.manager.utils.ObjectUtils;

@RequestMapping("testResultLevel")
@Controller
public class YrTestResultLevelController extends GenericController<YrTestResultLevelForm, YrTestResultLevel>{

	@Autowired
	private YrTestResultLevelService selfService;
	
	@RequestMapping("findAll")
	@ResponseBody
	public HTTPResult<YrTestResultLevelForm> findAll() throws Exception{
		HTTPResult<YrTestResultLevelForm> result = new HTTPResult<YrTestResultLevelForm>();
		List<YrTestResultLevel> entityList = selfService.findAll();
		
		List<YrTestResultLevelForm> formList = new ArrayList<YrTestResultLevelForm>();
		for(YrTestResultLevel entity : entityList){
			formList.add(toForm(entity));
		}
		
		result.setData(formList);
		return result;
	}
	
	@Override
	public YrTestResultLevelForm toForm(YrTestResultLevel e) throws Exception {
		YrTestResultLevelForm form = ObjectUtils.objectToObject(e, YrTestResultLevelForm.class);
		return form;
	}

	@Override
	public YrTestResultLevel toEntity(YrTestResultLevelForm f) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
